---
title: Streaming Agent
---

## Code

```python cookbook/models/lmstudio/basic_stream.py
from typing import Iterator  # noqa
from agno.agent import Agent, RunOutput  # noqa
from agno.models.lmstudio import LMStudio

agent = Agent(model=LMStudio(id="qwen2.5-7b-instruct-1m"), markdown=True)

# Get the response in a variable
# run_response: Iterator[RunOutputEvent] = agent.run("Share a 2 sentence horror story", stream=True)
# for chunk in run_response:
#     print(chunk.content)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story", stream=True)
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

<Step title="Install LM Studio">
  Install LM Studio from [here](https://lmstudio.ai/download) and download the
  model you want to use.
</Step>

<Step title="Install libraries">```bash pip install -U agno ```</Step>

  <Step title="Run Agent">
    <CodeGroup>
    ```bash Mac
    python cookbook/models/lmstudio/basic_stream.py
    ```

    ```bash Windows
    python cookbook/models/lmstudio/basic_stream.py
    ```
    </CodeGroup>

  </Step>
</Steps>
